﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.NeuralNets
{
	public class Layer
	{
		public int InputCount { get; private set; }
		public Node[] Nodes { get; private set; }

		public Layer(int size, int inputCount)
		{
			this.Nodes = new Node[size];
			for (int i = 0; i < size; i++)
			{
				this.Nodes[i] = new Node(inputCount);
			}
		}

		protected void ValidateInputVector(double[] inputVector)
		{
			ArgumentValidation.CheckNullArgument("inputVector", inputVector);
			if (inputVector.Length != this.InputCount)
			{
				throw new ArgumentException("Incorrect sized inputVector", "inputVector");
			}
		}

		public double[] Activate(double[] inputVector)
		{
			this.ValidateInputVector(inputVector);

			double[] z = new double[this.Nodes.Length];
			for (int i = 0; i < this.Nodes.Length; i++)
			{
				z[i] = this.Nodes[i].Activate(inputVector);
			}

			return z;
		}
	}
}
